<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" th:href="@{lib/layui-v2.5.5/css/layui.css}" media="all">
    <link rel="stylesheet" th:href="@{css/public.css}" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter">

        </table>

        <script type="text/html" id="currentTableBar">
            <button class="layui-btn layui-btn-normal layui-btn-sm data-add-btn" lay-event="add"> 报废</button>

        </script>

    </div>
</div>
<script th:src="@{lib/layui-v2.5.5/layui.js}" charset="utf-8"></script>

<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table;

        table.render({
            elem: '#currentTableId',
            url: 'asset/assetByStatus',
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [
                [
                    {field: 'id', width: 100, title: '资产ID', sort: true},
                    {field: 'name', width: 100, title: '资产名'},
                    {field: 'type', width: 100, title: '类型'},
                    {field: 'model', width: 100, title: '型号'},
                    {field: 'price', width: 100, title: '产品价格', sort: true},
                    {field: 'createTime', width: 200, title: '入库时间', sort: true},
                    {field: 'remarks',width: 200,title: '备注'},
                    {
                        field: 'status', title: '状态', width: 100,
                        templet: function (res) {
                            if (res.status == 1) {
                                return '<span class="layui-badge layui-bg-blue">库外</span>';
                            } else if (res.status == 2) {
                                return '<span class="layui-badge-rim">正常</span>';
                            } else if (res.status == 3) {
                                return '<span class="layui-badge layui-bg-red">异常</span>';
                            }
                        }
                    },
                    {title: '操作', minWidth: 150, toolbar: '#currentTableBar', align: "center"}
                ]
            ],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line',
            id: 'testReload'
        });


        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });




        table.on('tool(currentTableFilter)', function (obj) {
            var data = obj.data;
            if (obj.event === 'add') {//报废  添加assetScrap表,维修价格,备注,
                var index = layer.open({
                    title: '资产报废',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['50%', '50%'],
                    content: 'addScrap?aId='+data.id,
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });

    });
</script>

</body>
</html>